﻿using System.IO;
using UnityEngine;
using Framework.AssetsManager;

public class Utility {

    public static FlatBuffers.ByteBuffer LoadTableDataFile(string tablePath)
    {
        TextAsset data = (TextAsset)RM.Instance.GetResource("tabledata/" + tablePath);
        return new FlatBuffers.ByteBuffer(data.bytes);
    }

    public static void LogError(string str)
    {
        System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace();
        string method = trace.ToString().Split('\n')[1];
        method = method.Substring(method.IndexOf("at ") + 3);
        string currFrame = Time.frameCount.ToString("0000000");
        string currTime = (Time.realtimeSinceStartup * 1000).ToString("00000");
        string fullMsg = "[" + currFrame + "@" + currTime + "]" + method + "::" + str;
        Debug.LogError(fullMsg + "\n");
        System.Console.WriteLine(fullMsg);
        //Debug.LogError(str);
    }

    public static readonly string DataPath = Application.dataPath + "/Resources/TableData";
}
